<script type="text/javascript">
    $(document).ready(function() {
        $("#tabsdetails").tytabs({
            tabinit:"1",
            fadespeed:"fast"
        });
        
        $('.ca2').show();
    });
    
    function toggleSemaine(el) {
        var elId = $(el).attr('id');
        
        if ($(el).hasClass('plus')) {
            $(el).removeClass('plus');
            $(el).addClass('moins');            
            $('#tabsdetails .'+elId).fadeIn('fast');
        } else if ($(el).hasClass('moins')) {
            $(el).removeClass('moins');
            $(el).addClass('plus');
            $('#tabsdetails .'+elId).fadeOut('fast');
        }
    }
</script>
<?php
//var_dump($period);
// Boucle sur les mois
foreach ($period as $idxm => $month) {
    $monthExpload = explode(" ", $idxm);
    $monthName = $monthExpload[0];
    
    $monthRows[$idxm] = "";
    $monthRowsTop[$idxm] = "";
    $monthRowsCa[$idxm] = "";
    $monthRowsCaContent[$idxm] = "";
    $monthRowsEc[$idxm] = "";
    $monthRowsEcContent[$idxm] = "";
    $monthRowsPopr[$idxm] = "";
    $monthRowsPoprContent[$idxm] = "";
    $monthRowsTv[$idxm] = "";
    $monthRowsTvContent[$idxm] = "";    
    $monthRowsMo[$idxm] = "";
    $monthRowsMoContent[$idxm] = "";
    $monthRowsTsf[$idxm] = "";
    $monthRowsTsfContent[$idxm] = "";
    $monthRowsAc[$idxm] = "";
    $monthRowsAcContent[$idxm] = "";
    $monthRowsMt[$idxm] = "";
    $monthRowsMtContent[$idxm] = "";
    $monthRowsBq[$idxm] = "";
    $monthRowsBqContent[$idxm] = "";
    $monthRowsBq2[$idxm] = "";
    $monthRowsBqContent2[$idxm] = "";
    $monthRowsCc[$idxm] = "";
    $monthRowsCcContent[$idxm] = "";
    
    $monthRows[$idxm] .= '
        <div class="monthRow">
            <table>';
    
    $monthRowsTop[$idxm] .= '
        <tr class="tr-details-top">
            <th></th>
            <th class="width175 th-detail-month"><p>'.$idxm.'</p></th>';
    
    $monthRowsCa[$idxm] .= '
        <tr class="ca2">
            <td class="td-detail-label"><p><nobr>CA TTC / CA HT</nobr></p></td>
            <td></td>';
    
    $monthRowsEc[$idxm] .= '
        <tr class="ec2">
            <td class="td-detail-label"><p><nobr>Ecarts caisse</nobr></p></td>
            <td></td>';
    
    $monthRowsPopr[$idxm] .= '
        <tr class="popr2">
            <td class="td-detail-label"><p><nobr>Pertes / Offerts / Repas</nobr></p></td>
            <td></td>';
    
    $monthRowsTv[$idxm] .= '
        <tr class="tv2">
            <td class="td-detail-label"><p><nobr>Transactions / Nb ventes</nobr></p></td>
            <td></td>';
    
    $monthRowsMo[$idxm] .= '
        <tr class="mo2">
            <td class="td-detail-label"><p><nobr>Main d\'oeuvre</nobr></p></td>
            <td></td>';
    
    $monthRowsTsf[$idxm] .= '
        <tr class="tsf2 hide">
            <td class="td-detail-label"><p><nobr>Transferts</nobr></p></td>
            <td></td>';
    
    $monthRowsAc[$idxm] .= '
        <tr class="ac2">
            <td class="td-detail-label"><p><nobr>Annulations caisse</nobr></p></td>
            <td></td>';
    
    $monthRowsMt[$idxm] .= '
        <tr class="mt2 hide">
            <td class="td-detail-label"><p><nobr>Météo</nobr></p></td>
            <td></td>';
    
    $monthRowsBq[$idxm] .= '
        <tr class="bq2">
            <td class="td-detail-label"><p><nobr>CB / Espèce</nobr></p></td>
            <td></td>';
    
    $monthRowsBq2[$idxm] .= '
        <tr class="bq2">
            <td class="td-detail-label"><p><nobr>Chèque / Restaurant</nobr></p></td>
            <td></td>';
    
    $monthRowsCc[$idxm] .= '
        <tr class="cc2 hide">
            <td class="td-detail-label"><p><nobr>Comptes clients</nobr></p></td>
            <td></td>';
    // Boucle sur les semaines
    $y = 1;
    foreach ($month as $idxw => $week) { 
        if($echoMonthtoEn[$monthName] == date("F") && $idxw == date("W"))
            $plus_moins = "moins";
        else
            $plus_moins = "plus";
        
        $monthRowsTop[$idxm] .= '
            <th class="width175"><p>Semaine '.$y.'<span id="rps'.$monthName.$idxw.'" class="toogle '.$plus_moins.'" onclick="toggleSemaine(this);"></span></p></th>';
        
        $monthRowsCa[$idxm] .= '<th></th>';
        
        $monthRowsEc[$idxm] .= '<th></th>';
        
        $monthRowsPopr[$idxm] .= '<th></th>';
        
        $monthRowsTv[$idxm] .= '<th></th>';
        
        $monthRowsMo[$idxm] .= '<th></th>';
        
        $monthRowsTsf[$idxm] .= '<th></th>';
        
        $monthRowsAc[$idxm] .= '<th></th>';
        
        $monthRowsMt[$idxm] .= '<th></th>';
        
        $monthRowsBq[$idxm] .= '<th></th>';
        
        $monthRowsBq2[$idxm] .= '<th></th>';
        
        $monthRowsCc[$idxm] .= '<th></th>';
        
        // Boucle sur les jours
        foreach ($week as $idxd => $day) {
            if($echoMonthtoEn[$monthName] == date("F") && $idxw == date("W"))
                $hide = "";
            else
                $hide = "hide";
        
            $monthRowsTop[$idxm] .= '
                <th class="width175 '.$hide.' rps'.$monthName.$idxw.'"><p class="blackcolor">'.$idxd.'('.$day->format('d/m/Y').')</p></th>';
            
            $monthRowsCa[$idxm] .= '<td class="hide rps'.$idxw.'"></td>';
            
            $monthRowsEc[$idxm] .= '<td class="hide rps'.$idxw.'"></td>';
            
            $monthRowsPopr[$idxm] .= '<td class="hide rps'.$idxw.'"></td>';
            
            $monthRowsTv[$idxm] .= '<td class="hide rps'.$idxw.'"></td>';
            
            $monthRowsMo[$idxm] .= '<td class="hide rps'.$idxw.'"></td>';
            
            $monthRowsTsf[$idxm] .= '<td class="hide rps'.$idxw.'"></td>';
            
            $monthRowsAc[$idxm] .= '<td class="hide rps'.$idxw.'"></td>';
            
            $monthRowsMt[$idxm] .= '<td class="hide rps'.$idxw.'"></td>';
            
            $monthRowsBq[$idxm] .= '<td class="hide rps'.$idxw.'"></td>';
            
            $monthRowsBq2[$idxm] .= '<td class="hide rps'.$idxw.'"></td>';
            
            $monthRowsCc[$idxm] .= '<td class="hide rps'.$idxw.'"></td>';
        }
        $y++;
    }
    
    
    
    foreach($store as $ids => $storeName) {
        // Get CA for month
        $monthCATTC = $monthCAHT = 0;
        foreach($ca as $dca) {
            if($dca['idStore'] == $ids) {
                $explodeOrderDate = explode('-',$dca['orderDate']);
                $thisMonth = $monthText[intval($explodeOrderDate[1])]." ".$explodeOrderDate[0];            

                if($thisMonth == $idxm) {
                    $monthCATTC += $dca['ca_ttc'];
                    $monthCAHT += $dca['ca_ht'];
                }
            }
        }
        
        // Get EC for month
        $monthEC = 0;
        foreach($ec as $dec) {
            if($dec['idStore'] == $ids) {
                $explodeOrderDate = explode('-',$dec['date']);
                $thisMonth = $monthText[intval($explodeOrderDate[1])]." ".$explodeOrderDate[0];            

                if($thisMonth == $idxm) {
                    $monthEC += $dec['ec'];
                }
            }
        }
        
        // Get Banque for month
        $monthCb = $monthEs = $monthCq = $monthTr = 0;
        foreach($banque as $dbanque) {
            if($dbanque['idStore'] == $ids) {
                $explodeOrderDate = explode('-',$dbanque['date']);
                $thisMonth = $monthText[intval($explodeOrderDate[1])]." ".$explodeOrderDate[0];            

                if($thisMonth == $idxm) {
                    $monthCb += $dbanque['cb'];
                    $monthEs += $dbanque['espece'];
                    $monthCq += $dbanque['cheque'];
                    $monthTr += $dbanque['tr'];
                }
            }
        }
        
        // Get nbT for month
        $monthnbT = 0;
        foreach($nbT as $dnbT) {
            if($dnbT['idStore'] == $ids) {
                $explodeOrderDate = explode('-',$dnbT['orderDate']);
                $thisMonth = $monthText[intval($explodeOrderDate[1])]." ".$explodeOrderDate[0];            

                if($thisMonth == $idxm) {
                    $monthnbT += $dnbT['nbTransaction'];
                }
            }
        }
        
        // Get nbA for month
        $monthnbA = 0;
        foreach($nbA as $dnbA) {
            if($dnbA['idStore'] == $ids) {
                $explodeOrderDate = explode('-',$dnbA['orderDate']);
                $thisMonth = $monthText[intval($explodeOrderDate[1])]." ".$explodeOrderDate[0];            

                if($thisMonth == $idxm) {
                    $monthnbA += $dnbA['nbArticle'];
                }
            }
        }
        
        // Get Annulation Caisse for month
        $monthAc = 0;
        foreach($ac as $dac) {
            if($dac['idStore'] == $ids) {
                $explodeOrderDate = explode('-',$dac['orderDate']);
                $thisMonth = $monthText[intval($explodeOrderDate[1])]." ".$explodeOrderDate[0];            

                if($thisMonth == $idxm) {
                    $monthAc += $dac['ac'];
                }
            }
        }
        
        // Get Main d'oeuvre for month
        $monthMo = 0;
        foreach($rhdata as $data) {
            if($data['idStore'] == $ids) {
                $explodeOrderDate = explode('-',$data['date']);
                $thisMonth = $monthText[intval($explodeOrderDate[1])]." ".$explodeOrderDate[0];            

                if($thisMonth == $idxm) {
                    $monthMo += $data['mo'];
                }
            }
        }
        
        // Get Repas for month
        $monthRepas = 0;
        foreach($repas as $dRepas) {
            if($dRepas['idStore'] == $ids) {
                $explodeOrderDate = explode('-',$dRepas['orderDate']);
                $thisMonth = $monthText[intval($explodeOrderDate[1])]." ".$explodeOrderDate[0];            

                if($thisMonth == $idxm) {
                    $monthRepas += $dRepas['repas'];
                }
            }
        }
        
        $monthRowsCaContent[$idxm] .= '
            <tr class="ca2">
                <td class="td-detail-store"><p><nobr>'.$storeName.'</nobr></p></td>
                <td>
                    <table>
                        <tr>
                            <td class="detailValue" width="50%"><p>'.number_format($monthCATTC,2,',', ' ').'</p></td>
                            <td class="detailValue" width="50%"><p>'.number_format($monthCAHT,2,',', ' ').'</p></td>
                        </tr>
                    </table>
                </td>';
        
        $monthRowsEcContent[$idxm] .= '
            <tr class="ec2">
                <td class="td-detail-store"><p>'.$storeName.'</p></td>
                <td class="detailValue"><p>'.number_format($monthEC,2,',', ' ').'</p></td>';
        
        $monthRowsPoprContent[$idxm] .= '
            <tr class="popr2">
                <td class="td-detail-store"><p>'.$storeName.'</p></td>
                <td>
                    <table>
                        <tr>
                            <td class="detailValue" width="33%"><p>&nbsp;</p></td>
                            <td class="detailValue" width="33%"><p>&nbsp;</p></td>
                            <td class="detailValue" width="33%"><p>'.number_format($monthRepas,0,',', ' ').'</p></td>
                        </tr>
                    </table>
                </td>';
        
        $monthRowsTvContent[$idxm] .= '
            <tr class="tv2">
                <td class="td-detail-store"><p>'.$storeName.'</p></td>
                <td>
                    <table>
                        <tr>
                            <td class="detailValue" width="50%"><p>'.number_format($monthnbT,0,',', ' ').'</p></td>
                            <td class="detailValue" width="50%"><p>'.number_format($monthnbA,0,',', ' ').'</p></td>
                        </tr>
                    </table>
                </td>';
        
        $monthRowsMoContent[$idxm] .= '
            <tr class="mo2">
                <td class="td-detail-store"><p>'.$storeName.'</p></td>
                <td class="detailValue"><p>'.number_format($monthMo,2,',', ' ').'</p></td>';   
        
        $monthRowsTsfContent[$idxm] .= '
            <tr class="tsf2 hide">
                <td class="td-detail-store"><p>'.$storeName.'</p></td>
                <td>
                    <table>
                        <tr>
                            <td class="detailValue" width="50%"><p>'.number_format(0,0,',', ' ').'</p></td>
                            <td class="detailValue" width="50%"><p>'.number_format(0,0,',', ' ').'</p></td>
                        </tr>
                    </table>
                </td>';
        
        $monthRowsAcContent[$idxm] .= '
            <tr class="ac2">
                <td class="td-detail-store"><p>'.$storeName.'</p></td>
                <td class="detailValue"><p>'.number_format($monthAc,0,',', ' ').'</p></td>';
        
        $monthRowsMtContent[$idxm] .= '
            <tr class="mt2 hide">
                <td class="td-detail-store"><p>'.$storeName.'</p></td>
                <td>
                    <table>
                        <tr>
                            <td class="detailValue" width="50%"><p>'.number_format(0,0,',', ' ').'</p></td>
                            <td class="detailValue" width="50%"><p>'.number_format(0,0,',', ' ').'</p></td>
                        </tr>
                    </table>
                </td>';
        
        $monthRowsBqContent[$idxm] .= '
            <tr class="bq2">
                <td class="td-detail-store"><p>'.$storeName.'</p></td>
                <td>
                    <table>
                        <tr>
                            <td class="detailValue" width="50%"><p>'.number_format($monthCb,2,',', ' ').'</p></td>
                            <td class="detailValue" width="50%"><p>'.number_format($monthEs,2,',', ' ').'</p></td>
                        </tr>
                    </table>
                </td>';
        
        $monthRowsBqContent2[$idxm] .= '
            <tr class="bq2">
                <td class="td-detail-store"><p>'.$storeName.'</p></td>
                <td>
                    <table>
                        <tr>
                            <td class="detailValue" width="50%"><p>'.number_format($monthCq,2,',', ' ').'</p></td>
                            <td class="detailValue" width="50%"><p>'.number_format($monthTr,2,',', ' ').'</p></td>
                        </tr>
                    </table>
                </td>';
        
        $monthRowsCcContent[$idxm] .= '
            <tr class="cc2 hide">
                <td class="td-detail-store"><p>'.$storeName.'</p></td>
                <td>
                    <table>
                        <tr>
                            <td class="detailValue" width="50%"><p>'.number_format(0,0,',', ' ').'</p></td>
                            <td class="detailValue" width="50%"><p>'.number_format(0,0,',', ' ').'</p></td>
                        </tr>
                    </table>
                </td>';
        
        foreach ($month as $idxw => $week) { 
            // Get CA for week
            $weekCATTC = $weekCAHT = 0;                                    
            foreach($ca as $dca) {
                if($dca['idStore'] == $ids) {
                    $orderDate = new \DateTime($dca['orderDate']);            
                    $orderDateWeek = $orderDate->format('W');

                    $explodeOrderDate = explode('-',$dca['orderDate']);
                    $thisMonth = $monthText[intval($explodeOrderDate[1])]." ".$explodeOrderDate[0];

                    if($orderDateWeek == $idxw && $thisMonth == $idxm) {
                        $weekCATTC += $dca['ca_ttc'];
                        $weekCAHT += $dca['ca_ht'];
                    }
                }
            }
            
            // Get EC for week
            $weekEC = 0;                                    
            foreach($ec as $dec) {
                if($dec['idStore'] == $ids) {
                    $orderDate = new \DateTime($dec['date']);            
                    $orderDateWeek = $orderDate->format('W');

                    $explodeOrderDate = explode('-',$dec['date']);
                    $thisMonth = $monthText[intval($explodeOrderDate[1])]." ".$explodeOrderDate[0];

                    if($orderDateWeek == $idxw && $thisMonth == $idxm) {
                        $weekEC += $dec['ec'];
                    }
                }
            }
            
            // Get Banque for week
            $weekCb = $weekEs = $weekCq = $weekTr = 0;                                    
            foreach($banque as $dbanque) {
                if($dbanque['idStore'] == $ids) {
                    $orderDate = new \DateTime($dbanque['date']);            
                    $orderDateWeek = $orderDate->format('W');

                    $explodeOrderDate = explode('-',$dbanque['date']);
                    $thisMonth = $monthText[intval($explodeOrderDate[1])]." ".$explodeOrderDate[0];

                    if($orderDateWeek == $idxw && $thisMonth == $idxm) {
                        $weekCb += $dbanque['cb'];
                        $weekEs += $dbanque['espece'];
                        $weekCq += $dbanque['cheque'];
                        $weekTr += $dbanque['tr'];
                    }
                }
            }
            
            // Get nbT for week
            $weeknbT = 0;                                    
            foreach($nbT as $dnbT) {
                if($dnbT['idStore'] == $ids) {
                    $orderDate = new \DateTime($dnbT['orderDate']);            
                    $orderDateWeek = $orderDate->format('W');

                    $explodeOrderDate = explode('-',$dnbT['orderDate']);
                    $thisMonth = $monthText[intval($explodeOrderDate[1])]." ".$explodeOrderDate[0];

                    if($orderDateWeek == $idxw && $thisMonth == $idxm) {
                        $weeknbT += $dnbT['nbTransaction'];
                    }
                }
            }
            
            // Get nbA for week
            $weeknbA = 0;                                    
            foreach($nbA as $dnbA) {
                if($dnbA['idStore'] == $ids) {
                    $orderDate = new \DateTime($dnbA['orderDate']);            
                    $orderDateWeek = $orderDate->format('W');

                    $explodeOrderDate = explode('-',$dnbA['orderDate']);
                    $thisMonth = $monthText[intval($explodeOrderDate[1])]." ".$explodeOrderDate[0];

                    if($orderDateWeek == $idxw && $thisMonth == $idxm) {
                        $weeknbA += $dnbA['nbArticle'];
                    }
                }
            }
            
            // Get Annulation Caisse for week
            $weekAc = 0;                                    
            foreach($ac as $dac) {
                if($dac['idStore'] == $ids) {
                    $orderDate = new \DateTime($dac['orderDate']);            
                    $orderDateWeek = $orderDate->format('W');

                    $explodeOrderDate = explode('-',$dac['orderDate']);
                    $thisMonth = $monthText[intval($explodeOrderDate[1])]." ".$explodeOrderDate[0];

                    if($orderDateWeek == $idxw && $thisMonth == $idxm) {
                        $weekAc += $dac['ac'];
                    }
                }
            }
            
            // Get MO for week
            $weekMo = 0;                                    
            foreach($rhdata as $data) {
                if($data['idStore'] == $ids) {
                    $orderDate = new \DateTime($data['date']);            
                    $orderDateWeek = $orderDate->format('W');

                    $explodeOrderDate = explode('-',$data['date']);
                    $thisMonth = $monthText[intval($explodeOrderDate[1])]." ".$explodeOrderDate[0];

                    if($orderDateWeek == $idxw && $thisMonth == $idxm) {
                        $weekMo += $data['mo'];
                    }
                }
            }
            
            // Get Repas for week
            $weekRepas = 0;                                    
            foreach($repas as $dRepas) {
                if($dRepas['idStore'] == $ids) {
                    $orderDate = new \DateTime($dRepas['orderDate']);            
                    $orderDateWeek = $orderDate->format('W');

                    $explodeOrderDate = explode('-',$dRepas['orderDate']);
                    $thisMonth = $monthText[intval($explodeOrderDate[1])]." ".$explodeOrderDate[0];

                    if($orderDateWeek == $idxw && $thisMonth == $idxm) {
                        $weekRepas += $dRepas['repas'];
                    }
                }
            }
                                                     
            $monthRowsCaContent[$idxm] .= '
                <td>
                    <table>
                        <tr>
                            <td class="detailValue" width="50%"><p>'.number_format($weekCATTC,2,',', ' ').'</p></td>
                            <td class="detailValue" width="50%"><p>'.number_format($weekCAHT,2,',', ' ').'</p></td>
                        </tr>
                    </table>
                </td>';
            
            $monthRowsEcContent[$idxm] .= '<td class="detailValue"><p>'.number_format($weekEC,2,',', ' ').'</p></td>';
            $monthRowsPoprContent[$idxm] .= '
                <td>
                    <table>
                        <tr>
                            <td class="detailValue" width="33%"><p>&nbsp;</p></td>
                            <td class="detailValue" width="33%"><p>&nbsp;</p></td>
                            <td class="detailValue" width="33%"><p>'.number_format($weekRepas,0,',', ' ').'</p></td>
                        </tr>
                    </table>
                </td>';
            $monthRowsTvContent[$idxm] .= '
                <td>
                    <table>
                        <tr>
                            <td class="detailValue" width="50%"><p>'.number_format($weeknbT,0,',', ' ').'</p></td>
                            <td class="detailValue" width="50%"><p>'.number_format($weeknbA,0,',', ' ').'</p></td>
                        </tr>
                    </table>
                </td>';
            $monthRowsMoContent[$idxm] .= '<td class="detailValue"><p>'.number_format($weekMo,2,',', ' ').'</p></td>';
            $monthRowsTsfContent[$idxm] .= '
                <td>
                    <table>
                        <tr>
                            <td class="detailValue" width="50%"><p>'.number_format(0,2,',', ' ').'</p></td>
                            <td class="detailValue" width="50%"><p>'.number_format(0,2,',', ' ').'</p></td>
                        </tr>
                    </table>
                </td>';
            $monthRowsAcContent[$idxm] .= '<td class="detailValue"><p>'.number_format($weekAc,0,',', ' ').'</p></td>';
            $monthRowsMtContent[$idxm] .= '
                <td>
                    <table>
                        <tr>
                            <td class="detailValue" width="50%"><p>'.number_format(0,2,',', ' ').'</p></td>
                            <td class="detailValue" width="50%"><p>'.number_format(0,2,',', ' ').'</p></td>
                        </tr>
                    </table>
                </td>';
            $monthRowsBqContent[$idxm] .= '
                <td>
                    <table>
                        <tr>
                            <td class="detailValue" width="50%"><p>'.number_format($weekCb,2,',', ' ').'</p></td>
                            <td class="detailValue" width="50%"><p>'.number_format($weekEs,2,',', ' ').'</p></td>
                        </tr>
                    </table>
                </td>';
            $monthRowsBqContent2[$idxm] .= '
                <td>
                    <table>
                        <tr>
                            <td class="detailValue" width="50%"><p>'.number_format($weekCq,2,',', ' ').'</p></td>
                            <td class="detailValue" width="50%"><p>'.number_format($weekTr,2,',', ' ').'</p></td>
                        </tr>
                    </table>
                </td>';
            $monthRowsCcContent[$idxm] .= '
                <td>
                    <table>
                        <tr>
                            <td class="detailValue" width="50%"><p>'.number_format(0,2,',', ' ').'</p></td>
                            <td class="detailValue" width="50%"><p>'.number_format(0,2,',', ' ').'</p></td>
                        </tr>
                    </table>
                </td>';
            
            foreach ($week as $idxd => $day) {
                if($echoMonthtoEn[$monthName] == date("F") && $idxw == date("W"))
                    $hide = "";
                else
                    $hide = "hide";
            
                // Get CA for day
                $dayCATTC = $dayCAHT = 0;
                foreach ($ca as $dca) {
                    if($dca['idStore'] == $ids) {
                        if($dca['orderDate'] == $day->format('Y-m-d')) {
                            $dayCATTC = $dca['ca_ttc'];
                            $dayCAHT = $dca['ca_ht'];
                        }
                    }
                }
                
                // Get EC for day
                $dayEC = 0;
                foreach ($ec as $dec) {
                    if($dec['idStore'] == $ids) {
                        if($dec['date'] == $day->format('Y-m-d')) {
                            $dayEC = $dec['ec'];
                        }
                    }
                }
                
                // Get Banque for day
                $dayCb = $dayEs = $dayCq = $dayTr = 0;
                foreach ($banque as $dbanque) {
                    if($dbanque['idStore'] == $ids) {
                        if($dbanque['date'] == $day->format('Y-m-d')) {
                            $dayCb = $dbanque['cb'];
                            $dayEs = $dbanque['espece'];
                            $dayCq = $dbanque['cheque'];
                            $dayTr = $dbanque['tr'];
                        }
                    }
                }
                
                // Get nbT for day
                $daynbT = 0;
                foreach ($nbT as $dnbT) {
                    if($dnbT['idStore'] == $ids) {
                        if($dnbT['orderDate'] == $day->format('Y-m-d')) {
                            $daynbT = $dnbT['nbTransaction'];
                        }
                    }
                }
                
                // Get nbA for day
                $daynbA = 0;
                foreach ($nbA as $dnbA) {
                    if($dnbA['idStore'] == $ids) {
                        if($dnbA['orderDate'] == $day->format('Y-m-d')) {
                            $daynbA = $dnbA['nbArticle'];
                        }
                    }
                }
                
                // Get Annulation caisse for day
                $dayAc = 0;
                foreach ($ac as $dac) {
                    if($dac['idStore'] == $ids) {
                        if($dac['orderDate'] == $day->format('Y-m-d')) {
                            $dayAc = $dac['ac'];
                        }
                    }
                }
                
                // Get MO for day
                $dayMo = 0;
                foreach ($rhdata as $data) {
                    if($data['idStore'] == $ids) {
                        if($data['date'] == $day->format('Y-m-d')) {
                            $dayMo = $data['mo'];
                        }
                    }
                }
                
                // Get Repas for day
                $dayRepas = 0;
                foreach ($repas as $dRepas) {
                    if($dRepas['idStore'] == $ids) {
                        if($dRepas['orderDate'] == $day->format('Y-m-d')) {
                            $dayRepas = $dRepas['repas'];
                        }
                    }
                }
                                    
                $monthRowsCaContent[$idxm] .= '
                    <td class="'.$hide.' rps'.$monthName.$idxw.'">
                        <table>
                            <tr>
                                <td class="detailValue" width="50%"><p>'.number_format($dayCATTC,2,',', ' ').'</p></td>
                                <td class="detailValue" width="50%"><p>'.number_format($dayCAHT,2,',', ' ').'</p></td>
                            </tr>
                        </table>
                    </td>';
                $monthRowsEcContent[$idxm] .= '
                    <td class="detailValue '.$hide.' rps'.$monthName.$idxw.'">
                        <p>'.number_format($dayEC,2,',', ' ').'</p>
                    </td>';
                $monthRowsPoprContent[$idxm] .= '
                    <td class="'.$hide.' rps'.$monthName.$idxw.'">
                        <table>
                            <tr>
                                <td class="detailValue" width="33%"><p>&nbsp;</p></td>
                                <td class="detailValue" width="33%"><p>&nbsp;</p></td>
                                <td class="detailValue" width="33%"><p>'.number_format($dayRepas,0,',', ' ').'</p></td>
                            </tr>
                        </table>
                    </td>';
                $monthRowsTvContent[$idxm] .= '
                    <td class="'.$hide.' rps'.$monthName.$idxw.'">
                        <table>
                            <tr>
                                <td class="detailValue" width="50%"><p>'.number_format($daynbT,0,',', ' ').'</p></td>
                                <td class="detailValue" width="50%"><p>'.number_format($daynbA,0,',', ' ').'</p></td>
                            </tr>
                        </table>
                    </td>';
                $monthRowsMoContent[$idxm] .= '
                    <td class="detailValue '.$hide.' rps'.$monthName.$idxw.'">
                        <p>'.number_format($dayMo,2,',', ' ').'</p>
                    </td>';
                $monthRowsTsfContent[$idxm] .= '
                    <td class="'.$hide.' rps'.$monthName.$idxw.'">
                        <table>
                            <tr>
                                <td class="detailValue" width="50%"><p>'.number_format(0,2,',', ' ').'</p></td>
                                <td class="detailValue" width="50%"><p>'.number_format(0,2,',', ' ').'</p></td>
                            </tr>
                        </table>
                    </td>';
                $monthRowsAcContent[$idxm] .= '
                    <td class="detailValue '.$hide.' rps'.$monthName.$idxw.'">
                        <p>'.number_format($dayAc,0,',', ' ').'</p>
                    </td>';
                $monthRowsMtContent[$idxm] .= '
                    <td class="'.$hide.' rps'.$monthName.$idxw.'">
                        <table>
                            <tr>
                                <td class="detailValue" width="50%"><p>'.number_format(0,2,',', ' ').'</p></td>
                                <td class="detailValue" width="50%"><p>'.number_format(0,2,',', ' ').'</p></td>
                            </tr>
                        </table>
                    </td>';
                $monthRowsBqContent[$idxm] .= '
                    <td class="'.$hide.' rps'.$monthName.$idxw.'">
                        <table>
                            <tr>
                                <td class="detailValue" width="50%"><p>'.number_format($dayCb,2,',', ' ').'</p></td>
                                <td class="detailValue" width="50%"><p>'.number_format($dayEs,2,',', ' ').'</p></td>
                            </tr>
                        </table>
                    </td>';
                $monthRowsBqContent2[$idxm] .= '
                    <td class="'.$hide.' rps'.$monthName.$idxw.'">
                        <table>
                            <tr>
                                <td class="detailValue" width="50%"><p>'.number_format($dayCq,2,',', ' ').'</p></td>
                                <td class="detailValue" width="50%"><p>'.number_format($dayTr,2,',', ' ').'</p></td>
                            </tr>
                        </table>
                    </td>';
                $monthRowsCcContent[$idxm] .= '
                    <td class="'.$hide.' rps'.$monthName.$idxw.'">
                        <table>
                            <tr>
                                <td class="detailValue" width="50%"><p>'.number_format(0,2,',', ' ').'</p></td>
                                <td class="detailValue" width="50%"><p>'.number_format(0,2,',', ' ').'</p></td>
                            </tr>
                        </table>
                    </td>';
            }
        }
        
        $monthRowsCaContent[$idxm] .= '</tr>';  
    }
    
    
    
    $monthRowsTop[$idxm] .= '</tr>';    
    $monthRowsCa[$idxm] .= '</tr>'.$monthRowsCaContent[$idxm];
    $monthRowsEc[$idxm] .= '</tr>'.$monthRowsEcContent[$idxm];
    $monthRowsPopr[$idxm] .= '</tr>'.$monthRowsPoprContent[$idxm];
    $monthRowsTv[$idxm] .= '</tr>'.$monthRowsTvContent[$idxm];
    $monthRowsMo[$idxm] .= '</tr>'.$monthRowsMoContent[$idxm];
    $monthRowsTsf[$idxm] .= '</tr>'.$monthRowsTsfContent[$idxm];
    $monthRowsAc[$idxm] .= '</tr>'.$monthRowsAcContent[$idxm];
    $monthRowsMt[$idxm] .= '</tr>'.$monthRowsMtContent[$idxm];
    $monthRowsBq[$idxm] .= '</tr>'.$monthRowsBqContent[$idxm];
    $monthRowsBq2[$idxm] .= '</tr>'.$monthRowsBqContent2[$idxm];
    $monthRowsCc[$idxm] .= '</tr>'.$monthRowsCcContent[$idxm];
    
    $monthRows[$idxm] .= $monthRowsTop[$idxm];
    $monthRows[$idxm] .= $monthRowsCa[$idxm];
    $monthRows[$idxm] .= $monthRowsEc[$idxm];
    $monthRows[$idxm] .= $monthRowsPopr[$idxm];
    $monthRows[$idxm] .= $monthRowsTv[$idxm];
    $monthRows[$idxm] .= $monthRowsMo[$idxm];
    $monthRows[$idxm] .= $monthRowsTsf[$idxm];
    $monthRows[$idxm] .= $monthRowsAc[$idxm];
    $monthRows[$idxm] .= $monthRowsMt[$idxm];
    $monthRows[$idxm] .= $monthRowsBq[$idxm];
    $monthRows[$idxm] .= $monthRowsBq2[$idxm];
    $monthRows[$idxm] .= $monthRowsCc[$idxm];
    
    $monthRows[$idxm] .= '
            </table>
        </div>';
}
?>

<div id="tabsdetails">
    <?php 
        foreach($monthRows as $row) {
            echo $row;
        }
    ?>
</div>